<!doctype HTML>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<p>This tests for a bug when moving the caret forward by a line from a range
selection with a horizontal position for vertical arrow navigation set. To
match TextEdit, the caret should be between the second and third 'x's in the
forth paragraph.</p>
<div id="sample" contenteditable>
xxx<br>
xxx<br>
x<br>
xxx<br id="afterAnchor">
</div>
<div id="log"></div>
<script>
test(function() {
    var selection = window.getSelection();
    var sample = document.getElementById('sample');
    selection.collapse(sample, 0);
    selection.modify('move', 'forward', 'character');
    selection.modify('move', 'forward', 'character');
    selection.modify('extend', 'forward', 'line');
    selection.modify('extend', 'forward', 'line');
    selection.modify('move', 'forward', 'line');

    var anchor = document.getElementById('afterAnchor').previousSibling;
    assert_equals(selection.anchorNode, anchor, 'anchorNode');
    assert_equals(selection.anchorOffset, 3, 'anchorOffset');
    assert_equals(selection.focusNode, anchor, 'focusNode');
    assert_equals(selection.focusOffset, 3, 'focusOffset');
});
</script>
